﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ClassDemoFlight
{
    class Program
    {
        static void Main(string[] args)
        {
            string ch = "n";

            List<Flight> flights = new List<Flight>();

            do
            {
                Console.Clear();
                Flight newFlight = new Flight();
                newFlight.FlightInfo();
                flights.Add(newFlight);
                Console.WriteLine("Do you want to enter next flight? y/n");
                ch = Console.ReadLine().ToLower();
            } while (ch == "y");
            Console.Clear();
            Console.WriteLine("Search for destination point");
            Console.Write("Enter destination point: ");
            string userDestPoint = Console.ReadLine();
            foreach (var newFlight in flights)
            {
                if (newFlight.destination == userDestPoint)
                    newFlight.PrintFlightInfo();
            }
        }
        class Flight
        {
            public string destination;
            public string flightNumber;
            public string planeModel;
            public string travelTimeInHours;

            public void FlightInfo()
            {
                Console.WriteLine("Информация о рейсе");
                Console.WriteLine("Введите пункт назначения:");
                destination = Console.ReadLine();
                Console.WriteLine("Введите номер рейса:");
                flightNumber = Console.ReadLine();
                Console.WriteLine ("Введите модель самолёта: ");
                planeModel = Console.ReadLine();
                Console.WriteLine("Время в пути: ");
                travelTimeInHours = Console.ReadLine();
            }
            public void PrintFlightInfo()
            {
                Console.Clear();
                Console.WriteLine("Номер рейса {0} - Пункт назначения {1} - Модель самолёта {2} - Время в пути {3}", flightNumber, destination, planeModel, travelTimeInHours);

            }
        }
    }
}
